package com.huanmeiqi.forkjoin.vo;

import java.util.Random;

/**
 * @author cq.Wang
 * @date 2018/8/7 15:45
 * @description
 */
public class PeachFactory {


    public PeachFactory() {
    }

    public Peach[] makeArray(Integer size) {
        Random colorRandom = new Random();
        Random sizeRandom = new Random();
        Random yearRandom = new Random();

        Peach[] array = new Peach[size];
        for (int i = 0; i < size; i++) {
            Peach peach = new Peach();
            peach.setColor(colorRandom.nextBoolean() ? Color.RED : Color.GREEN);
            peach.setSize(sizeRandom.nextBoolean() ? Size.BIG : Size.SMALL);
            peach.setYear(yearRandom.nextInt(10001));
            array[i] = peach;
        }

        return array;
    }

    public static void main(String[] args) {
        PeachFactory peachArray = new PeachFactory();
        Peach[] peaches = peachArray.makeArray(10);
        for (Peach peach : peaches) {
            System.out.println(peach);
        }
    }
}
